<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>注册用户</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <style>
        th {
            text-align: center;
        }

        td {
            text-align: center;
        }

    </style>

    <script language="JavaScript" type="text/javascript">
        //判断规则（正则表达式）
        function goto() {
            var name = document.getElementById("username");
            var pwd = document.getElementById("userpassword");
            var pwd2 = document.getElementById("password");

            var telephone = document.getElementById("userphone");
            var email = document.getElementById("useremail");
            if (name.value.trim().length < 2) {
                alert("用户名长度须大于2位");
                name.focus()
                name.value = "";
                return;
            }
//        规则必须包括大小写字母，数字
            var regex = /^(?!(?:\d+|[a-zA-Z]+|[\da-z]+|[\dA-Z])$)[\da-zA-Z]{6,}$/;
//        var regex = /^[A-z0-9]{10,20}$/;
            if (!pwd.value.match(regex)) {
                alert("密码规定8到16位");
                pwd.focus()
                pwd.value = "";
                return;
            }
            if (pwd.value != pwd2.value) {
                alert("两次输入的密码不相同");
                pwd2.focus()
                pwd.value = "";
                pwd2.value = "";
                return;
            }


            var regex3 = /^1[3,5,7,8]\d{9}$/;
            if (!regex3.test(telephone.value)) {
                alert("手机号码不符合规定");
                telephone.focus()
                telephone.value = "";
                return;
            }
            //test方法必须用反斜杠转义
            var regex4 = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            if (!regex4.test(email.value)) {
                alert("邮箱不符合规定");
                email.focus()
                email.value = "";
                return;
            }
        }
    </script>


</head>
<body>
<!-- 顶部开始 -->
<div th:replace="common1::#topbar"></div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<div class="wrapper">
    <!-- 左侧菜单开始 -->
    <div th:replace="common1::#leftbar"></div>
    <!-- 左侧菜单结束 -->
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="content">

            <fieldset class="layui-elem-field layui-field-title site-title">
                <legend><a name="default">添加用户信息</a></legend>
            </fieldset>
            <form class="layui-form" th:action="@{/doadd-user}" method="post">
                <div class="layui-form-item">
                    <label for="useraccount" class="layui-form-label">
                        <span class="x-red"></span>用户账户
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="useraccount" name="useraccount" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>


                </div>

                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red"></span>用户姓名
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="username" name="username" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <span class="x-red">长度大于2位</span>


                </div>


                <div class="layui-form-item">
                    <label for="userpassword" class="layui-form-label">
                        <span class="x-red"></span>账户密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="userpassword" name="userpassword" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                    <span class="x-red">长度大于十位，包含大小写字母和数字</span>


                </div>

                <div class="layui-form-item">
                    <label for="password" class="layui-form-label">
                        <span class="x-red"></span>确认密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="password" name="password" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>


                </div>

                <div class="layui-form-item">
                    <label for="usergender" class="layui-form-label">
                        <span class="x-red"></span>用户性别
                    </label>
                    <div class="layui-input-inline">
                        <select id="usergender" name="usergender" class="form-control">
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="userunit" class="layui-form-label">
                        <span class="x-red"></span>工作单位
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="userunit" name="userunit" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                </div>

                <div class="layui-form-item">
                    <label for="userphone" class="layui-form-label">
                        <span class="x-red"></span>用户电话
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="userphone" name="userphone" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                    <span class="x-red">11位整数</span>
                </div>

                <div class="layui-form-item">
                    <label for="useremail" class="layui-form-label">
                        <span class="x-red"></span>用户邮箱
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="useremail" name="useremail" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>

                </div>

                <div class="layui-form-item">
                    <label for="usertype" class="layui-form-label">
                        <span class="x-red"></span>用户类型
                    </label>
                    <div class="layui-input-inline">
                        <select id="usertype" name="usertype" class="form-control">
                            <option value="3">学生</option>
                            <option value="2">评委</option>
                            <option value="1">赛事管理员</option>
                        </select>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">
                    </label>
                    <input type="submit" name="添加" onclick="goto()" class="layui-btn">
                    <!--                      <button type="submit" name="添加"  class="layui-btn"></button>-->
                </div>
            </form>
            <!-- 右侧内容框架，更改从这里结束 -->
        </div>
    </div>
    <!-- 右侧主体结束 -->
</div>
<!-- 中部结束 -->
<!-- 底部开始 -->
<div th:replace="common1::#bottombar"></div>
<!-- 底部结束 -->
<!-- 背景切换开始 -->
<div th:replace="common1::#backbar"></div>
</body>
</html>